<template>
    <div class="visitor">
        <div class="top">
            <div class="left">
                <span class="free">{{ user.isInsure===1?'医保':'非医保' }}</span>
                <span class="username">{{ user.name }}</span>
            </div>
            <div class="right">
                <el-button circle type="primary" size="default" :icon="Edit" @click="$emit('changeScene')"></el-button>
                <el-button v-if="$route.path=='/user/patient'" circle type="primary" size="default" :icon="Delete"></el-button>
            </div>
        </div>
        <div class="bottom">
            <p>证件类型：{{ user.param.certificatesTypeString }}</p>
            <p>证件号码：{{ user.certificatesNo }}</p>
            <p>性别：{{ user.sex===1?'男':'女' }}</p>
            <p>出生日期：{{ user.birthdate }}</p>
            <p>手机号码：{{ user.phone }}</p>
            <p>婚姻状况：{{ user.isMarry===0?'未婚':'已婚' }}</p>
            <p>当前住址：{{ user.param.fullAddress }}</p>
            <!-- 标记已选择盒子-->
            <transition name="tag">
                <div class="confirm" v-if="index === userIndex">已选择</div>
            </transition>
        </div>
    </div>
</template>

<script lang="ts" setup name="Visitor">
    import {Delete, Edit} from "@element-plus/icons-vue";
    import {useRoute} from "vue-router";

    let $route = useRoute();

    // 接受父组件传来的就诊人
    const props = defineProps(['user','index','userIndex'])
    const $emit = defineEmits(['changeScene'])
</script>

<style scoped>
.visitor {
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.12);
    .top {
        height: 60px;
        background-color: #e5e5e5;
        display: flex;
        justify-content: space-between;
        align-items: center;

        .left {
            margin-left: 15px;
            flex:6;
            .free {
                background-color: white;
                padding: 5px;
                margin-right: 5px;
                border-radius: 10px;
            }

            .username {
                color: #7f7f7f;
                width:150px;
            }
        }

        .right {
            margin-right: auto;
            flex: 4;
            display: flex;
            justify-content: center;
        }
    }

    .bottom {
        padding: 20px;
        position: relative;
        p {
            line-height: 30px;
            font-size: 14px;
        }
        .confirm{
            position: absolute;
            width: 200px;
            height: 200px;
            color: red;
            border-radius: 50%;
            border: 1px dashed red;
            text-align: center;
            line-height: 200px;
            left:10%;
            top:20%;
            opacity: 0.4;
            transform: rotate(35deg);
            font-weight: 900;
        }
        /* 加载盒子动画 */
        .tag-enter-from{
            transform: scale(1);
        }
        .tag-enter-active{
            transition: all 0.5s;
        }
        .tag-enter-to{
            transform: scale(1.2);
        }
    }
}
.visitor:hover{
    cursor: pointer;
}
</style>